package com.zjp;

import com.google.common.base.Preconditions;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multimap;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class MultiTest {


    @Test
    public void t1() {

        String[] str = {"A", "B", "C", "C"};

        HashMultiset<String> hashMultiset = HashMultiset.create();


        hashMultiset.addAll(Arrays.asList(str));


        System.out.println("hashMultiset.count(\"C\") = " + hashMultiset.count("C"));
    }


    @Test
    public void t2() {


        Multimap<String, String> multimap = HashMultimap.create();

        multimap.put("A", "1");
        multimap.put("A", "2");

        System.out.println(multimap.get("A"));

    }

    @Test
    public void t3() {

        HashBiMap<String, String> hashBiMap = HashBiMap.create();

        hashBiMap.put("1", "2");

        String s = hashBiMap.inverse().get("2");
        Preconditions.checkArgument("1".equals(s), "获取失败");
        System.out.println(s);

    }

}
